package com.titan.core.utils.object;

import com.titan.core.utils.data.FormatUtils;
import com.titan.core.utils.dbinfo.bean.ColumnBean;

/**
 * @author 周成功
 * @email 86898837@qq.com
 * @date 2020年02月14日
 */
public class TableDescriptor {
    private String nameEnglish;    
    private String nameChina;
    private String comments;
    private String type;
    private String[] primaryKey;
    private String[][] uniqueIndex;
    private ListMap<String, TableColumnDescriptor> columns = new ListMap<String, TableColumnDescriptor>();

    
    public TableDescriptor() {
    }
    
    public TableColumnDescriptor getColumn(String name) {
        return columns.get(name.toLowerCase());
    }
    
    public String toString() {
        StringBuffer info =new StringBuffer(1024);
        info.append("nameEnglish="+nameEnglish+",");
        info.append("nameChina="+nameChina+",");
        info.append("comments="+comments+",");
        info.append("type="+type+",");
        info.append("primaryKey="+FormatUtils.toString(primaryKey)+",");
        info.append("uniqueIndex="+FormatUtils.toString(uniqueIndex)+",");
        info.append("[");
        for (int i = 0; i < columns.size(); i++) {
            if(i>0) {
                info.append(",");
            }
            info.append(columns.getValue(i).toString());
        }
        info.append("]");
        return info.toString();
    }


    public String getNameEnglish() {
        return nameEnglish;
    }
    
    public void setNameEnglish(String nameEnglish) {
        this.nameEnglish = nameEnglish;
    }
    
    public String getNameChina() {
        return nameChina;
    }
    
    public void setNameChina(String nameChina) {
        this.nameChina = nameChina;
    }
    
    public String getComments() {
        return comments;
    }
    
    public void setComments(String comments) {
        this.comments = comments;
    }
    
    public String getType() {
        return type;
    }
    
    public void setType(String type) {
        this.type = type;
    }
    
    public String[] getPrimaryKey() {
        return primaryKey;
    }
    
    public void setPrimaryKey(String[] primaryKey) {
        this.primaryKey = primaryKey;
    }
    
    public String[][] getUniqueIndex() {
        return uniqueIndex;
    }

    public void setUniqueIndex(String[][] uniqueIndex) {
        this.uniqueIndex = uniqueIndex;
    }

    public ListMap<String, TableColumnDescriptor> getColumns() {
        return columns;
    }

    public void setColumns(TableColumnDescriptor[] columns) {
        for (int i = 0; i < columns.length; i++) {
            this.columns.put(columns[i].getNameEnglish().toLowerCase(), columns[i]);
        }
    }
}
